<?php

namespace app\web\controller;
use app\web\model\LineShiftModel;
use app\common\controller\StoreBaseController;
use app\common\model\Csv;

use think\Db;
//use vendor\PHPExcel\PHPExcel;
/**
 * 交班列表
 */
class LineShiftController extends StoreBaseController
{
 	protected $model;
	
    protected function _initialize() {
        parent::_initialize();
        $this->model = new LineShiftModel();        
    }
    /**
     * 交班列表
     * @author [longx] 
     */
    public function index( $page = 1){
    	if(request()->isPost()){
		 	$param = input('post.');
			//操作员
			if($param['mobile']){
				$where['mobile'] = ['like', '%'.$param['mobile'].'%'];
			}
			//总收入
			if($param['total_icomes']){
				$where['total_icome'] = ['between', [$param['total_icomes'],$param['total_icomee']]];
			}
			//交班时间
			if($param['start_time']&&$param['end_time']){
				$where['add_time'] = ['between time', [$param['start_time'],$param['end_time']]];
			}		 				
	 	}
		
    	$where['store_id']= session('storeInfo')['id'];
        $list = $this->model->where($where)->order('add_time desc')->paginate(10);
        return $this->fetch('index', ['list' => $list]);
    }

    /**
     * [del删除]
     * @author [longx] 
     */
    public function delete()
    {
        $id = input('param.id');
        if ($this->model->destroy($id)) {
            $this->success('删除成功');
        } else {
            $this->error('删除失败');
        }
    }
}